﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Maticsoft.Common;
public partial class SellerAdd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void cmdAd_Click(object sender, EventArgs e)
    {
        string strErr = "";
    

        if (this.txtSellerName.Text.Trim().Length == 0)
        {
            strErr += "SellerName不能为空！\\n";
        }
        if (!PageValidate.IsNumber(ddSellerType.SelectedValue))
        {
            strErr += "SellerType格式错误！\\n";
        }
        if (this.txtAddress.Text.Trim().Length == 0)
        {
            strErr += "Address不能为空！\\n";
        }
       
        if (this.txtTelephone.Text.Trim().Length == 0)
        {
            strErr += "Telephone不能为空！\\n";
        }
        if (this.txtBusinessTime.Text.Trim().Length == 0)
        {
            strErr += "BusinessTime不能为空！\\n";
        }
        if (this.txtBusinessArea.Text.Trim().Length == 0)
        {
            strErr += "BusinessArea不能为空！\\n";
        }
     
      
        if (this.txtDiscountCard.Text.Trim().Length == 0)
        {
            strErr += "DiscountCard不能为空！\\n";
        }
        
        if (this.txtHasPart.Text.Trim().Length == 0)
        {
            strErr += "HasPart不能为空！\\n";
        }
        if (this.txtBusStop.Text.Trim().Length == 0)
        {
            strErr += "BusStop不能为空！\\n";
        }
        if (this.txtBusLine.Text.Trim().Length == 0)
        {
            strErr += "BusLine不能为空！\\n";
        }
    
      
        if (strErr != "")
        {
            MessageBox.Show(this, strErr);
            return;
        }

        string SellerName = this.txtSellerName.Text;
        int SellerType = int.Parse(this.ddSellerType.SelectedValue);
        string Address = this.txtAddress.Text;
        string Province ="";
        string City = "";
        string Area = "";
        string Telephone = this.txtTelephone.Text;
        string BusinessTime = this.txtBusinessTime.Text;
        string BusinessArea = this.txtBusinessArea.Text;
        int AvgComsumption = 0;
        String IsSupportCard = "Y";
        if (this.RadioButton1.Checked == true)
        {
            IsSupportCard = "Y";
        }
        else
        {
            IsSupportCard = "N";
        }

        string DiscountCard = this.txtDiscountCard.Text;
        string HasPart = this.txtHasPart.Text;
        string BusStop = this.txtBusStop.Text;
        string BusLine = this.txtBusLine.Text;
      
   
        com.Model.laibendi.T_Seller model = new com.Model.laibendi.T_Seller();     
        model.MemberId = 0;
        model.SellerName = SellerName;
        model.SellerType = SellerType;
        model.Address = Address;
        model.Province = Province;
        model.City = City;
        model.Area = Area;
        model.Telephone = Telephone;
        model.BusinessTime = BusinessTime;
        model.BusinessArea = BusinessArea;
        model.AvgComsumption = AvgComsumption;
        model.IsSupportCard = IsSupportCard;
        model.DiscountCard = DiscountCard;
        model.Grade = 0;
        model.HasPart = HasPart;
        model.BusStop = BusStop;
        model.BusLine = BusLine;
        model.Intro = "";
        model.feature = "";
        model.logo = "";
        model.DiscountContent = "";

        com.BLL.laibendi.T_Seller bll = new com.BLL.laibendi.T_Seller();
        bll.Add(model);
        Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "Default.aspx");
    }
}
